import http from '@/http'

const prefix = '/api/hanzi'
const path = `${prefix}/character`

export default {
  /**
   * 获取所有汉字字符
   */
  async findAll() {
    const res = await http({
      method: 'GET',
      path,
      params: {},
    })
    return res
  },

  /**
   * 根据 ID 获取汉字字符
   * @param id 汉字字符 ID
   */
  async findById(id: number) {
    const res = await http({
      method: 'GET',
      path: `${path}/${id}`,
      params: {},
    })
    return res
  },

  /**
   * 创建汉字字符
   * @param params 汉字字符数据
   */
  async create(params: any) {
    const res = await http({
      method: 'POST',
      path,
      params,
    })
    return res
  },

  /**
   * 更新汉字字符
   * @param params 汉字字符数据
   */
  async update(params: any) {
    const res = await http({
      method: 'PUT',
      path: `${path}/${params.id}`,
      params,
    })
    return res
  },

  /**
   * 根据 ID 删除汉字字符
   * @param id 汉字字符 ID
   */
  async deleteById(id: number) {
    const res = await http({
      method: 'DELETE',
      path: `${path}/${id}`,
      params: {},
    })
    return res
  },
}